angular.module('${menuCode}')
.controller("${widgetCode}Ctrl",function($scope,AppKit){
	$scope.closeModal = function() {
		AppKit.closeModal();
	};
	
	$scope.loadCostListData = function() {
		var url='/aeaiem/services/DailyReiDataProvider/rest/daily-rei-Detail/'+$scope.detailId ;
		var promise = AppKit.getJsonApi(url);  
		promise.success(function(rspJson){
			$scope.costData = rspJson;
		})
	}
	
	if($scope.operationType == "edit"){
		$scope.buttonShowState = true;
		$scope.saveButtonState = false;
		$scope.submitButtonState = false;
		$scope.loadCostListData();
	}else if($scope.operationType == "insert"){
		$scope.buttonShowState = true;
		$scope.costData = new DetailInfo();
		
		$scope.saveButtonState = false;
		$scope.submitButtonState = true;
		
		var url='/aeaiem/services/DailyReiDataProvider/rest/get-select-list/ER_STYLE';
		var promise = AppKit.getJsonApi(url);  
		promise.success(function(rspJson){
			$scope.costData.styleSelect= rspJson;
			$scope.costData.operationType  = $scope.operationType;
		})
	 }else if($scope.operationType == "detail"){
		$scope.buttonShowState = false;
		$scope.loadCostListData();
		
	}
	
	$scope.saveDetailInfo = function() {
		var url ='/aeaiem/services/DailyReiDataProvider/rest/save-detail-info/';
		$scope.costData.operationType  = $scope.operationType;
		AppKit.postJsonApi(url,$scope.costData).then(function(rspJson){
			AppKit.successPopup({"title":"保存成功!"});
			$scope.loadCostListDatas();
			AppKit.closeModal();
			AppKit.hideMask();
		}); 
	}
	
	$scope.submitDetailInfo = function() {
		var url ='/aeaiem/services/DailyReiDataProvider/rest/submit-detail-info/';
		AppKit.postJsonApi(url,$scope.costData).then(function(rspJson){
			AppKit.successPopup({"title":"提交成功!"});
			$scope.loadCostListDatas();
			AppKit.closeModal();
			AppKit.hideMask();
		}); 
	}
	
	
	 function DetailInfo(){ 
         this.theme = '';
         this.money = '';
         this.desc = '';
         this.style = '';
         this.styleSelect ="";
      }
	
	
});